package com.gome.wechat.program.dao;

import com.gome.wechat.program.entity.GroupActivity;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * Created by liwei113 on 2017/10/31 0031.
 */
public interface GroupActivityRepo extends JpaRepository<GroupActivity, Long> {
	
	@Query(value = "select ga from GroupActivity ga where ga.id in ?1")
	List<GroupActivity> getListInActivityIds(List<Long> activityIds);
	
	@Query(value = "select ga from GroupActivity ga where ga.publisherId = :publisherId")
	List<GroupActivity> getListByPublisherId(@Param("publisherId") Long publisherId);
	
	
	
	@Query(value = "select ga from GroupActivity ga where ga.appointmentLongitude < :longitudeRight and ga.appointmentLongitude > :longitudeLeft and ga.appointmentLatitude > :latitudeUp and ga.appointmentLatitude < :latitudeDown")
	List<GroupActivity> getGroupActivityByCoordinate(@Param("longitudeLeft") Double longitudeLeft,@Param("longitudeRight") Double longitudeRight,
			@Param("latitudeUp") Double latitudeUp,@Param("latitudeDown") Double latitudeDown);



//	@Query(value = "select tag_name tagName,address_desc addressDesc, current_longitude currentLongitude,current_latitude currentLatitude, appointment_longitude appointmentLongitude,appointment_latitude appointmentLatitude from group_activity where type = 2 ",nativeQuery=true)
	@Query(value = "select ga from GroupActivity ga where ga.type = 2 ")
	List<GroupActivity> getGroupActivityByTypeTwoAndLimitOne();
}
